<?php
namespace App\Http\Controllers\ApiApp;

use App\DBs\AppVersionDB;
use Illuminate\Http\Request;

class SysController extends BaseController
{
    /**
     * 系统参数
     */

    protected $db;

    public function __construct()
    {
        parent::__construct();
        $this->db = new AppVersionDB();
    }

//    /**
//     * 判断系统参数
//     */
//    public function getIndex(Request $request)
//    {
//        $appAccess = $request->post('appAccess','');
//        $appDomain = $request->post('appDomain','');
//        $resAccess = $this->db->getAccess($appAccess);
//        $nextDomain = env('NEXTDOMAIN');
//        if (!$resAccess || $appDomain!=$nextDomain) {
//            return $this->toAppJson(-2);
//        }
//        return $this->toAppJson(0);
//    }

    /**
     * 设置系统参数
     */
    public function setUpdate(Request $request)
    {
        $appAccess = $request->post('appAccess','');
        $resAccess = $this->db->getAccessLast($appAccess);
        if (!$resAccess) {
            $resAccess = $this->db->setAccess();
        }
        $nextDomain = env('NEXTDOMAIN');
        $dataArr = array(
            'appAccess' => $resAccess,
            'appDomain' => $nextDomain,
        );
        return $this->toAppJson(0,$dataArr);
    }
}
